package com.example.yunhailutong.zhongtan.fragment;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.yunhailutong.zhongtan.R;
import com.lljjcoder.style.citypickerview.CityPickerView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;

import butterknife.BindView;
import butterknife.Unbinder;


/**
 * A simple {@link Fragment} subclass.
 */
public class FuJinBaseFragment extends BaseFragment {
    SmartRefreshLayout refreshLayout;
    ViewPager vpViewpager;
    TabLayout tabSelect;
    @BindView(R.id.title)
    TextView title;
    Unbinder unbinder;
    private View view;
    private String cityid = "";
    private CityPickerView mPicker;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        view = inflater.inflate(R.layout.fragment_fujin_base, container, false);
//        refreshLayout = view.findViewById(R.id.refreshLayout);
//        vpViewpager = view.findViewById(R.id.vp_viewpager);
//        tabSelect = view.findViewById(R.id.tab_select);
//        final String[] tiltes = {"供应信息", "需求信息"};
//        vpViewpager.setAdapter(new MainBaseFragmentPagerAdapter(getActivity().getSupportFragmentManager(), tiltes, cityid));
//        tabSelect.setSelectedTabIndicatorColor(Color.parseColor("#ff6600"));
//        tabSelect.setTabTextColors(Color.parseColor("#000000"), Color.parseColor("#ff6600"));
//        tabSelect.setTabGravity(GRAVITY_FILL);
//        tabSelect.setupWithViewPager(vpViewpager);
//        refreshLayout.setOnRefreshListener(new OnRefreshListener() {
//            @Override
//            public void onRefresh(RefreshLayout refreshlayout) {
//                //传入false表示刷新失败
//                refreshlayout.finishRefresh();
//                String[] tiltes = {"供应信息", "需求信息"};
//                vpViewpager.setAdapter(new MainBaseFragmentPagerAdapter(getActivity().getSupportFragmentManager(), tiltes, cityid));
//                tabSelect.setTabTextColors(Color.parseColor("#000000"), Color.parseColor("#ff6600"));
//                tabSelect.setSelectedTabIndicatorColor(Color.parseColor("#ff6600"));
//                tabSelect.setTabGravity(GRAVITY_FILL);
//                tabSelect.setupWithViewPager(vpViewpager);
//            }
//        });
//        mPicker = new CityPickerView();
//        mPicker.init(getContext());
//        unbinder = ButterKnife.bind(this, view);
//        title.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                CityConfig cityConfig = new CityConfig.Builder().build();
//                mPicker.setConfig(cityConfig);
//
//                //监听选择点击事件及返回结果
//                mPicker.setOnCityItemClickListener(new OnCityItemClickListener() {
//                    @Override
//                    public void onSelected(ProvinceBean province, CityBean city, DistrictBean district) {
//                        String s = "";
//                        //省份
//                        if (province != null) {
//                            s = province.getName();
//                        }
//                        //城市
//                        if (city != null) {
//                            s = s + city.getName();
//                        }
//                        //地区
//                        if (district != null) {
//                            s = s + district.getName();
//                            cityid = district.getId();
//                            title.setText(district.getName());
//                        }
//                        String[] tiltes = {"供应信息", "需求信息"};
//                        vpViewpager.setAdapter(new MainBaseFragmentPagerAdapter(getActivity().getSupportFragmentManager(), tiltes, cityid));
//                        tabSelect.setTabTextColors(Color.parseColor("#000000"), Color.parseColor("#ff6600"));
//                        tabSelect.setSelectedTabIndicatorColor(Color.parseColor("#ff6600"));
//                        tabSelect.setTabGravity(GRAVITY_FILL);
//                        tabSelect.setupWithViewPager(vpViewpager);
//                    }
//
//                    @Override
//                    public void onCancel() {
//                        ToastUtils.showLongToast(getActivity(), "已取消");
//                    }
//                });
//                //显示
//                mPicker.showCityPicker();
//            }
//        });
        return view;
    }

    @Override
    public void onClick(View v) {

    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }
}
